﻿package frEngine.loaders.resource.info
{
    import com.gengine.resource.info.*;
    import flash.events.*;
    import flash.utils.*;
    import frEngine.*;
    import frEngine.event.*;
    import frEngine.manager.*;

    public class Info3dBase extends DataInfo implements IEventDispatcher
    {
        public var proceedParsed:Boolean = false;
        public var needReload:Boolean;
        protected var _dispatcher:EventDispatcher;

        public function Info3dBase(param1:Object)
        {
            this._dispatcher = new EventDispatcher(this);
            super(param1);
            return;
        }// end function

        public function reload() : void
        {
            this.needReload = false;
            if (!this.isLoaded)
            {
                Resource3dManager.instance.load(name, null, 0);
            }
            return;
        }// end function

        override public function get cacheBytes() : ByteArray
        {
            return null;
        }// end function

        override public function set cacheBytes(param1:ByteArray) : void
        {
            return;
        }// end function

        override protected function writeCacheBytes(param1:ByteArray) : void
        {
            return;
        }// end function

        public function proceedParsing() : void
        {
            if (this.proceedParsed || !_byteArray)
            {
                return;
            }
            this.proceedParsed = true;
            FrEventDispatcher.instance.proxyDispatchEvent(this, Engine3dEventName.PARSE_RESOURCE_FINISH);
            return;
        }// end function

        public function addEventListener(param1:String, param2:Function, param3:Boolean = false, param4:int = 0, param5:Boolean = false) : void
        {
            this._dispatcher.addEventListener(param1, param2, param3, param4, param5);
            return;
        }// end function

        public function removeEventListener(param1:String, param2:Function, param3:Boolean = false) : void
        {
            this._dispatcher.removeEventListener(param1, param2, param3);
            return;
        }// end function

        public function hasEventListener(param1:String) : Boolean
        {
            return this._dispatcher.hasEventListener(param1);
        }// end function

        public function willTrigger(param1:String) : Boolean
        {
            return this._dispatcher.willTrigger(param1);
        }// end function

        public function dispatchEvent(event:Event) : Boolean
        {
            return this._dispatcher.dispatchEvent(event);
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            this.needReload = false;
            return;
        }// end function

        override public function dispose() : void
        {
            if (isLoaded)
            {
                super.dispose();
            }
            this.needReload = true;
            FrEventDispatcher.instance.removeAllProxyEventListener(this);
            if (_byteArray)
            {
                this._byteArray.clear();
                this._byteArray = null;
            }
            this.clearCacheBytes();
            return;
        }// end function

        override public function clearCacheBytes() : void
        {
            super.clearCacheBytes();
            this.proceedParsed = false;
            return;
        }// end function

    }
}
